return value
Calling functions are free to receive return values or ignore them. Functions are
also free to return values or not. When a function returns no value, the compiler
returns a zero in the data type declared for the function.
The following examples illustrate that there can be any number of RETURN and EXIT FUNCTION
statements in a function, but only one END FUNCTION:
FUNCTION blivit ()
RETURN ' return zero/empty string
RETURN (a+b*c+d) ' return result of expression "(a+b*c+d)"
EXIT FUNCTION ' return zero / empty string
EXIT FUNCTION (retval) ' return the value of variable "retval"
END FUNCTION final ' return the value of variable "final"
function call
Functions sometimes appear in expressions in much the same way as algebraic functions, the
value returned by the function being one value in the evaluation of the expression.
For example:
a = b * Func (c,d) + e
Sometimes the value returned by a function is unimportant, but the actions performed by it are desired, as in the following example:
Func (c,d)
computed funtion call
Sometimes the function to be executed in an expression depends upon the value of a
variable or expression. For these situations, computed function calls through
variables and arrays of the FUNCADDR data type are provided. The addresses of
functions can be loaded into FUNCADDR variables and arrays during program execution.
When a FUNCADDR variable or array appears in an expression with a @ prefix, the
function whose address is read from the variable is called. For example:
a = b * @funcVar(j) + e
a = b * @funcArray[c,d](x,y) + e
In this example, variable j is an argument to the function whose address was most
recently assigned to FUNCADDR variable funcVar. Variables x and y are arguments to
the function whose address was most recently assigned to FUNCADDR array element
funcArray[c,d].
Sometimes the return value from a computed function invocation is not needed, but the
action performed by it is. For example:
@funcVar (j)
@funcArray[c,d](x,y)